package cn.ecnu.user.util;

import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;

import java.util.UUID;

//@Component
public class Encryptor {

    public String encrypt(String password, String salt) {
        for (int i = 0; i < 3; i++) {
            password = DigestUtils.md5DigestAsHex((salt + password + salt).getBytes()).toUpperCase();
        }
        return password;
    }

    public String salt() {
        return UUID.randomUUID().toString().toUpperCase();
    }
}
